package com.cqie.rbac.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.cqie.rbac.bo.TimeTaleBo;
import com.cqie.rbac.entity.TimetableView;
import com.cqie.rbac.mapper.TimetableViewMapper;
import com.cqie.rbac.service.ITimetableViewService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cqie.rbac.util.MyPageHelper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * VIEW 服务实现类
 * </p>
 *
 * @author 单机吧
 * @since 2021-10-12
 */
@Service
public class TimetableViewServiceImpl extends ServiceImpl<TimetableViewMapper, TimetableView> implements ITimetableViewService {



    @Override
    public List<TimetableView> getTimeTableList(TimeTaleBo bo) {
        if (bo.getPageNum() == null || bo.getPageSize() == null){
            bo.setPageNum(1);
            bo.setPageSize(10);
        }
        MyPageHelper.startPage(bo);
        LambdaQueryWrapper<TimetableView> lqw = Wrappers.lambdaQuery();
        lqw.eq(bo.getStudentId() != null,TimetableView::getStudentId,bo.getStudentId());
        lqw.likeRight(bo.getCName() != null,TimetableView::getCName,bo.getCName());
        lqw.likeRight(bo.getClassName() != null,TimetableView::getClassName,bo.getClassName());
        lqw.likeRight(bo.getTermName() != null,TimetableView::getTermName,bo.getTermName());
        lqw.eq(bo.getYear() != null,TimetableView::getYear,bo.getYear());
        List<TimetableView> timetableViews = baseMapper.selectList(lqw);
        return timetableViews;
    }
}
